package com.guo.erp;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ContactAdapter extends BaseAdapter {
	private Context mContext;
	private ArrayList<Contact> result;
	TextView mNameText;
	TextView mDustyText;
	TextView mDeptText;
	TextView mSubDeptText;
	TextView mNumText;

	public ContactAdapter(Context mContext, ArrayList<Contact> result) {
		super();
		this.mContext = mContext;
		this.result = result;
	}

	public int getCount() {

		return result.size();
	}

	@Override
	public Object getItem(int position) {

		return result.get(position);
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View view = LayoutInflater.from(mContext).inflate(R.layout.main2, null);
        mNameText=(TextView)view.findViewById(R.id.textView1);
        mDustyText=(TextView)view.findViewById(R.id.textView2);
        mDeptText=(TextView)view.findViewById(R.id.textView3);
        mSubDeptText=(TextView)view.findViewById(R.id.imageView4);
        Contact contact=result.get(position);
        mNameText.setText(contact.mName);
        mDustyText.setText(contact.mDusty);
        mDeptText.setText(contact.mDept);
        mSubDeptText.setText(contact.mSubDept); 
		return view;
	}

}
